<template>
    <div @mouseenter="deleteVisible = true" @mouseleave="deleteVisible = false">
        <div class="user_container" v-if="user.type === 'formUserList'">
            <span class="icon iconfont cgsIcon-user"></span>
            <span class="name">{{user.userAlia}}</span>
        </div>
        <div class="user_container" v-if="user.type === 'formNode'">
            <span class="name">{{user.outputItem.nodeName}}</span>
            <span class="nodename">{{user.fieldItem.alia}}</span>
        </div>
        <a-icon class="user_close" @click="handleDelete" v-show="deleteVisible" type="close" />
    </div>
</template>

<script>
export default {
    props:{
        user: Object,
    },
    data(){
        return {
            deleteVisible: false
        }
    },
    methods:{
        handleDelete(){
            this.$emit('deleteuser', this.user.userId)
        }
    }
}
</script>

<style lang="less">
.user_container{
    margin: 2px auto;
    border: 1px solid #ddd;
    background: #f5f5f5;
    height: 28px;
    border-radius: 26px;
    align-items: center;
    display: inline-flex;
    max-width: 250px;
    box-sizing: border-box;

    .icon{
        width: 25px;
        height: 25px;
        text-align: center;
        line-height: 25px;
        border-radius: 50%;
        color: #fff;
        background-color: #1890ff;
    }
    .nodename{
        border-radius: 26px;
        padding: 0 10px;
        color: #fff;
        font-weight: bold;
        background-color: #01ca83;
    }

    .name{
        color: #333;
        font-weight: bold;
        margin-left: 10px;
        padding-right: 12px;
    }
}

.user_close{
    margin-left: 10px;
    cursor: pointer;
}
</style>